package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.system.domain.vo.StaticVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DownloadLogMapper;
import com.ruoyi.system.domain.DownloadLog;
import com.ruoyi.system.service.IDownloadLogService;

/**
 * downLogService业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-30
 */
@Service
public class DownloadLogServiceImpl implements IDownloadLogService 
{
    @Autowired
    private DownloadLogMapper downloadLogMapper;

    /**
     * 查询downLog
     * 
     * @param id downLog主键
     * @return downLog
     */
    @Override
    public DownloadLog selectDownloadLogById(Long id)
    {
        return downloadLogMapper.selectDownloadLogById(id);
    }

    /**
     * 查询downLog列表
     * 
     * @param downloadLog downLog
     * @return downLog
     */
    @Override
    public List<DownloadLog> selectDownloadLogList(DownloadLog downloadLog)
    {
        return downloadLogMapper.selectDownloadLogList(downloadLog);
    }

    /**
     * 新增downLog
     * 
     * @param downloadLog downLog
     * @return 结果
     */
    @Override
    public int insertDownloadLog(DownloadLog downloadLog)
    {
        downloadLog.setUserId(SecurityUtils.getUserId());
        downloadLog.setIp(IpUtils.getIpAddr());
        downloadLog.setCreateTime(DateUtils.getNowDate());
        return downloadLogMapper.insertDownloadLog(downloadLog);
    }

    /**
     * 修改downLog
     * 
     * @param downloadLog downLog
     * @return 结果
     */
    @Override
    public int updateDownloadLog(DownloadLog downloadLog)
    {
        return downloadLogMapper.updateDownloadLog(downloadLog);
    }

    /**
     * 批量删除downLog
     * 
     * @param ids 需要删除的downLog主键
     * @return 结果
     */
    @Override
    public int deleteDownloadLogByIds(Long[] ids)
    {
        return downloadLogMapper.deleteDownloadLogByIds(ids);
    }

    /**
     * 删除downLog信息
     * 
     * @param id downLog主键
     * @return 结果
     */
    @Override
    public int deleteDownloadLogById(Long id)
    {
        return downloadLogMapper.deleteDownloadLogById(id);
    }

    @Override
    public List<StaticVo> downTotal(String beginTime, String endTime) {
        return downloadLogMapper.downTotal(beginTime,endTime);
    }

    @Override
    public List<StaticVo> downTotalNum(String beginTime, String endTime) {
        return downloadLogMapper.downTotalNum(beginTime,endTime);
    }
}
